using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;

public partial class admin_A_Chitiet_PhieuDeal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        string id = Request.QueryString["MaPhieu"].ToString();
        Phieu_Deal_DTO phieuDeal = Phieu_Deal_BUS.GetByID(id);

        int total = 0;
        Criteria cri = new Criteria();
        cri.add(Condition.AND, PhieuDealColumns.ID.ToString(), Condition.EQUAL, id);
        PhieuDealCollection pd = Phieu_Deal_BUS.Get(cri.Criter, 1, 1, PhieuDealColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = pd;
        Repeater1.DataBind();

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            int id = int.Parse(Request.QueryString["ID"].ToString());
            Phieu_Deal_DTO phieuDeal = (Phieu_Deal_DTO)e.Item.DataItem;

            HoaDon_DTO hoa_don = (HoaDon_DTO)e.Item.DataItem;

            Literal lit_khachhang = (Literal)e.Item.FindControl("l_KhachHang");
            KhachHang_DTO khachHang = KHACHHANG_BUS.GetByID(hoa_don.MaKH);
            lit_khachhang.Text = khachHang.HoTen;

            Literal hinh_thuc = (Literal)e.Item.FindControl("l_Hinhthucthanhtoan");
            HinhThucThanhToan_DTO hinhThuc = HinhThucThanhToan_BUS.GetByID(hoa_don.MaHinhThuc_ThanhToan);
            hinh_thuc.Text = hinhThuc.TenHinhThucThanhToan;

            Literal tinh_trang = (Literal)e.Item.FindControl("l_Tinhtrang");
            TinhTrang_DonHang_DTO tinhtrang = TinhTrang_DonHang_BUS.GetByID(hoa_don.MaTinhTrang_DH);
            tinh_trang.Text = tinhtrang.TenTinhTrang;

        }
    }
}
